package com.blogSystem.type.controller;

import com.blogSystem.type.pojo.Like;
import com.blogSystem.type.pojo.Type;
import com.blogSystem.type.service.TypeService;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/type")
public class TypeController {

    @Autowired
    private TypeService typeService;
    @RequestMapping(value = "/get_type",method = RequestMethod.POST)
    public String get_type(String text){
        Type type=typeService.getType(text);
        return type.getId();
    }

@RequestMapping(value = "/matching_list",method = RequestMethod.POST)
    public List<String> getList(@RequestParam String user_id){
    Like like=new Like();
    return typeService.matchingList(user_id);
}

@RequestMapping(value = "/record",method = RequestMethod.PUT)
    public void record(@RequestParam String user_id, @RequestParam String type_id){
        Like like=new Like();
        like.setType_id(type_id);
        like.setUser_id(user_id);
        typeService.record(like);
}
}
